package com.amado.course31;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;


public class ComparatorStudent {
	public static void main(String[] args) {
		List list = Arrays.asList(new Student("张三1",9),new Student("张三2",19),new Student("张三3",10));
		Collections.sort(list, new Comparator() {
			@Override
			public int compare(Object o1, Object o2) {
				Student stu1 =(Student)o1;
				Student stu2 =(Student)o2;
				return stu1.getAge()-stu2.getAge();
			}
		});
		
		for(Object obj:list) {
			System.out.println(obj.toString());
		}
	}
}
